<?php

namespace App\Http\Controllers;

use App\Library\Requests\Base\BasePageRequest;
use App\Library\Requests\Base\SerialNumberRequest;
use App\Library\Requests\Base\SerialNumbersRequest;
use App\Library\Requests\Cart\CartAddRequest;
use App\Library\Requests\Cart\CartDeleteRequest;
use App\Library\Requests\Cart\CartEditRequest;
use App\Library\Service\CartService;
use Illuminate\Http\JsonResponse;

class CartController extends BaseController
{
    /**
     * @param CartService $service
     */
    public function __construct(CartService $service)
    {
        $this->service = $service;
    }

    /**
     * 列表
     * @return JsonResponse
     */
    public function list(): JsonResponse
    {
        return $this->service->list();
    }

    /**
     * 添加
     * @param CartAddRequest $request
     * @return JsonResponse
     */
    public function add(CartAddRequest $request): JsonResponse
    {
        return $this->service->add($request);
    }

    /**
     * 编辑
     * @param CartEditRequest $request
     * @return JsonResponse
     */
    public function edit(CartEditRequest $request): JsonResponse
    {
        return $this->service->edit($request);
    }

    /**
     * 删除
     * @param SerialNumbersRequest $request
     * @return JsonResponse
     */
    public function delete(SerialNumbersRequest $request): JsonResponse
    {
        return $this->service->delete($request);
    }

    /**
     * 购物车商品数量
     * @return JsonResponse
     *
     */
    public function count(): JsonResponse
    {
        return $this->service->count();
    }
}
